//
//  Me_OrderCell.swift
//  AirTravel
//
//  Created by tulip on 2021/9/5.
//

import UIKit

class Me_OrderCell: UITableViewCell ,UICollectionViewDelegate,UICollectionViewDataSource {
    
    @IBOutlet weak var box: UIView!
    
    var nameArr:Array<String>=[]
    var imgArr:Array<String>=[]
    @IBOutlet weak var collect: UICollectionView!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
        box.backgroundColor=UIColor.white
        box.layer.cornerRadius=5
        box.layer.masksToBounds=true
        
        let layout=UICollectionViewFlowLayout.init()
        layout.itemSize=CGSize(width: 60, height: 60)
        layout.scrollDirection = .horizontal
        layout.sectionInset=UIEdgeInsets(top: 15, left:15, bottom: 15, right: 15)
        layout.minimumLineSpacing=18
        
        collect.collectionViewLayout=layout
        collect.delegate=self
        collect.dataSource=self
        collect.isPagingEnabled=true
        collect.register(UINib(nibName: "OrderBtnColletcell", bundle: nil), forCellWithReuseIdentifier: "OrderBtnColletcell")
        imgArr=["机票m","酒店m","旅游m","火车票m","商城m", "积分兑换","组21拷贝-贵宾厅","组21拷贝2-接送机","组21拷贝3-道路救援","组21拷贝4-租车"]
        nameArr=["机票","酒店","旅游","火车票","商城", "积分兑换","贵宾厅","接送机","道路救援","租车"]
     
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
        self.selectionStyle = .none
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        imgArr.count
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell:OrderBtnColletcell=collectionView.dequeueReusableCell(withReuseIdentifier: "OrderBtnColletcell", for: indexPath) as! OrderBtnColletcell
        cell.lab.text=nameArr[indexPath.row]
        cell.img.image=UIImage(named: imgArr[indexPath.row])
        cell.tag=indexPath.row
        return cell
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let cell:OrderBtnColletcell=collectionView.cellForItem(at: indexPath) as! OrderBtnColletcell
        var vc: UIViewController = UIViewController()
        
        switch cell.tag {
        case 0:
            vc = RVCommonOrderManageController(type: .flight)
            
        case 1:
            vc = RVCommonOrderManageController(type: .hotel)
        
        case 2:
            vc = RVCommonOrderManageController(type: .travel)
            
        case 3:
            vc = RVCommonOrderManageController(type: .railway)
        
        case 4:
            vc = RVCommonOrderManageController(type: .shoppingMall)
            
        case 5:
            vc = RVCommonOrderManageController(type: .bonus)
            
        case 6:
            vc = RVVIPHouseController()
            
        case 7:
            vc = RVPickListController()
            
        case 8:
            vc = RVRescueListController()
            
        case 9:
            vc = RVRentCarListController()
            
        default:
            vc = RVCommonOrderManageController(type: .flight)

        }
        
        vc.hidesBottomBarWhenPushed=true
        getCurrentVc().navigationController?.pushViewController(vc, animated: true)

    }
    
}
